/*
 * @Author: xiaoyan
 * @Date: 2021-09-08 18:08:36
 * @LastEditors: xiaoyan
 * @LastEditTime: 2021-09-08 19:21:52
 * @Description: 应用
 * @FilePath: \vue-ts-demo\src\store\modules\app.ts
 */
import { VuexModule, Module, Mutation, Action, getModule } from 'vuex-module-decorators'
import store from '@/store'

export enum DeviceType {
    Mobile,
    Desktop,
  }

export interface IAppState {
    device: DeviceType
    sidebar: {
        opened: boolean
        withoutAnimation: boolean
    }
    language: string
    size: string
}

@Module({ dynamic: true, store, name: 'app' })
class App extends VuexModule implements IAppState {
    public sidebar = {
        opened: false,
        withoutAnimation: false
    }
    public device = DeviceType.Desktop
    public language = 'zh'
    public size = 'medium'
    
    @Mutation
    private SET_LANGUAGE(language: string) {
        this.language = language
    }

    @Mutation
    private SET_SIZE(size: string) {
        this.size = size
    }

    @Action
    public SetLanguage(language: string) {
        this.SET_LANGUAGE(language)
    }

    @Action
    public SetSize(size: string) {
        this.SET_SIZE(size)
    }

}

export const AppModule = getModule(App)